<!DOCTYPE html>
<html lang='en'>

<head>
    <meta charset='UTF-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>Document</title>
    <script src='https://cdn.staticfile.org/react/16.4.0/umd/react.development.js'></script>
    <script src='https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js'></script>
    <!-- 生产环境中不建议使用 -->
    <script src='https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js'></script>
</head>

<body>
    <div id='app'>
    </div>
    <script type='text/babel'>
        // 开始看这里之前，请看一下同文件夹下的"补充一个知识点"文件
        class Weather extends React.Component{

            // 我们可以直接这样, 省去了在构造器里this.state....
            state = {isHot:true}

            // 可以直接这样简单粗暴的让changeWeather的this指向定死. 后续就无需再修改了
            changeWeather = ()=>{
                this.setState({isHot:!this.state.isHot})
            }

            render(){
                return <h1 onClick={this.changeWeather}>今天天气很{this.state.isHot?'炎热':'凉爽'}</h1>
            }
        }

        ReactDOM.render(<Weather/>,document.getElementById('app'))
    </script>
</body>

</html>